﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BUS;
using DTO;

public partial class ResultList : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        String type = Request.QueryString["type"];
        String type_name = Request.QueryString["name"];
        List<SanPhamDto> sanpham = null;
        if (type != null)
        {
            TheLoai.Text = type_name;

            sanpham = SanPhamBus.LayDanhSachSanPhamTheoLoai(int.Parse(type));

        }
        else if (type_name.Equals("khuyenmai"))
        {
            TheLoai.Text = "San Pham Khuyen Mai";
            sanpham = SanPhamBus.LayDanhSachSanKhuyenMai();
        }
        else if (type_name.Equals("moi"))
        {
            TheLoai.Text = "Sản Phẩm Mới";
            sanpham = SanPhamBus.LayDanhSachSanPham();
            for (int i = 0; i < sanpham.Count; i++)
            {
                if ((DateTime.Today - sanpham[i].NgayNhap).Days > 30)
                    sanpham.Remove(sanpham[i]);
            }
        }
        DataSanPham.DataSource = sanpham;
        DataSanPham.DataBind();
    }
}
